﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class UserControls_TH_SearchBox : System.Web.UI.UserControl
{
    private DataSet objDataSet;
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            LoadDanhSachNhaSanXuat();
        }
    }

    private void LoadDanhSachNhaSanXuat()
    {
        lstNhaSanXuat.Items.Clear();
        NhaSanXuatBUS objNSX = new NhaSanXuatBUS(TGDDConfiguration.DbConnectionString);
        objDataSet = objNSX.SelectNhaSanXuatByLoaiSanPham(1);

        ListItem item = new ListItem("- Nhà sản xuất -", "0");
        lstNhaSanXuat.Items.Add(item);
        for (int i = 0; i < objDataSet.Tables[0].Rows.Count; i++)
        {
            DataRow row = objDataSet.Tables[0].Rows[i];
            item = new ListItem(row["TenNSX"].ToString(), row["idNhaSanXuat"].ToString());
            lstNhaSanXuat.Items.Add(item);
        }
    }

    protected void btnSearch_Click(object sender, EventArgs e)
    {
        Response.Redirect(Request.ApplicationPath +
                "/KetQuaTimKiem.aspx?tukhoa=" + txtKeyword.Text +
                "&loaisp=1" +
                "&nsx=" + lstNhaSanXuat.SelectedValue.ToString() +
                "&giatu=" + lstPriceFrom.SelectedValue.ToString() +
                "&den=" + lstPriceTo.SelectedValue.ToString());
    }
}
